<template>
  <view class="xzjs">
    <view class="warning"
      >该号码匹配到多个账号，请选择需要登录的账号进行操作</view
    >
    <view
      class="info"
      v-for="(item, index) in infoData"
      :key="index"
      @tap="setStorage(item.roleId, item.userId, item.userType, item.username)"
    >
      <view class="item">
        <view>登陆账号</view>
        <view>{{ item.username }}</view>
      </view>
      <view class="item">
        <view>账号代理人</view>
        <view>{{ item.realName }}</view>
      </view>
      <view class="item">
        <view>所在部门</view>
        <view>{{ item.deptName }}</view>
      </view>
      <view class="item">
        <view>角色</view>
        <view>{{ getRole(item.roleId) }}</view>
      </view>
    </view>
  </view>
</template>

<script>
import { getSaveuser } from "../../request/dcxt";
export default {
  data() {
    return {
      infoData: [],
      path: "",
    };
  },
  onLoad(option) {
    this.infoData = JSON.parse(option.info);
    this.path = option.path;
    if (option.type == "sys_ducha") {
      uni.setNavigationBarTitle({
        title: "请选择督查角色",
      });
    }
    if (option.type == "sys_jixiao") {
      uni.setNavigationBarTitle({
        title: "请选择绩效角色",
      });
    }
    if (option.type == "sys_zhongda") {
      uni.setNavigationBarTitle({
        title: "请选择重大角色",
      });
    }
    if (option.type == "sys_jingji") {
      uni.setNavigationBarTitle({
        title: "请选择经济角色",
      });
    }
    if (option.type == "sys_zhaoshang") {
      uni.setNavigationBarTitle({
        title: "请选择招商角色",
      });
    }
  },
  methods: {
    getRole(id) {
      if (id == "01") {
        return "县领导";
      }
      if (id == "02") {
        return "主要领导";
      }
      if (id == "03") {
        return "分管领导";
      }
      if (id == "04") {
        return "经办人";
      }
    },
    setStorage(roleId, userId, userType, username) {
      uni.setStorageSync("roleId", roleId);
      uni.setStorageSync("loginId", userId);
      uni.setStorageSync("userType", userType);
      getSaveuser({
        userId: userId,
      }).then((res) => {});
      uni.navigateTo({
        url: this.path + "?username=" + username,
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.xzjs {
  width: 100%;
  min-height: 100vh;
  background-color: #f6f7fa;
  padding-top: 30rpx;

  .warning {
    margin-bottom: 30rpx;
    padding-left: 30rpx;
    font-size: 28rpx;
    font-family: PingFang SC;
    font-weight: bold;
    color: #272b32;
  }

  .info {
    width: 710rpx;
    background: #ffffff;
    box-shadow: 0rpx 0rpx 24rpx 0rpx rgba(48, 116, 255, 0.1);
    border-radius: 8rpx;
    margin: 0 auto;
    margin-bottom: 40rpx;
    padding: 40rpx 24rpx;

    .info_header {
      display: flex;
      flex-flow: row nowrap;
      justify-content: space-between;
      align-items: flex-start;

      view:nth-child(1) {
        font-size: 32rpx;
        font-family: PingFang SC;
        font-weight: bold;
        color: #272b32;
      }

      view:nth-child(2) {
        min-width: 120rpx;
        font-size: 24rpx;
        font-family: PingFang SC;
        font-weight: 500;
        color: #3074ff;
        text-align: center;
        padding: 8rpx 0rpx;
      }
    }

    .itemChildren {
      border-top: 1rpx solid rgba(231, 233, 240, 1);
      margin-top: 20rpx;
    }

    .state {
      display: inline-block;
      font-size: 20rpx;
      font-family: PingFang SC;
      font-weight: 400;
      color: #ffffff;
      border-radius: 4rpx;
      padding: 8rpx 16rpx;
      margin-top: 20rpx;
    }

    .item {
      display: flex;
      flex-flow: row nowrap;
      justify-content: flex-start;
      align-items: center;
      margin-top: 18rpx;

      view:nth-child(1) {
        width: 160rpx;
        font-size: 24rpx;
        font-family: PingFang SC;
        font-weight: 400;
        color: #8e9cb3;
      }

      view:nth-child(2) {
        font-size: 28rpx;
        font-family: PingFang SC;
        font-weight: 400;
        color: #272b32;
      }
    }
  }
}
</style>
